package net.repchain.browser.service.impl;

import com.github.pagehelper.PageInfo;
import net.repchain.browser.common.MyPageHelper;
import net.repchain.browser.common.WebPageInfo;
import net.repchain.browser.entity.RepchainBlock;
import net.repchain.browser.dao.RepchainBlockDao;
import net.repchain.browser.service.RepchainBlockService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (RepchainBlock)表服务实现类
 *
 * @author lhc
 * @since 2023-11-21 11:16:25
 */
@Service("repchainBlockService")
public class RepchainBlockServiceImpl implements RepchainBlockService {
    @Resource
    private RepchainBlockDao repchainBlockDao;


    @Override
    public RepchainBlock queryByHeight(Long height) {
        return repchainBlockDao.selectOne(RepchainBlock.builder().blockHeight(height).build());
    }

    /**
     * 分页查询
     *
     * @param repchainBlock 筛选条件
     * @param webPageInfo   分页对象
     * @return 查询结果
     */
    @Override
    public PageInfo<RepchainBlock> queryByPage(RepchainBlock repchainBlock, WebPageInfo webPageInfo) {
        MyPageHelper.<RepchainBlock>start(webPageInfo);
        return new PageInfo<>(repchainBlockDao.select(repchainBlock));
    }


}
